<%@page import="com.training.java.redbox.struts.domain.Movie"%>
<%@page import="com.training.java.redbox.struts.domain.Customer"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<title>Redbox</title>
</head>
<body bgcolor="white">
	<%@include file="Header.jsp"%>

		
	<c:set var="size" value="0"></c:set>
	<c:if test="${cart!=null}">
		<c:set var="size" value="${cart.size()}"></c:set>
	</c:if>
	
	<c:if test="${Customer!=null}">
		Welcome	 	<c:out value="${Customer.firstName}  ${Customer.lastName}">
		 	</c:out>
	</c:if>
	
	<br>
	
	<a href="/RedboxSpringMVC/logout.do"><img src="images/logout.jpg" width="90" height="40"></a>

	<table border="0" width="800" align="right">
		<tr>
			<td align="right"><a href="/RedboxSpringMVC/login.do"><img src="images/login.jpg" width="80" height="25"></a> 
			<a href="/RedboxSpringMVC/signup.do"><img src="images/signup2.jpg" width="80" height="25"></a>
			<img src="images/cart.jpg" width="30" height="25"/> (<c:out value="${size}"></c:out>)
			
			<c:choose>
			
				<c:when test="${cart!=null}">
				<a href="/RedboxSpringMVC/checkout.do"><img	src="images/checkout.jpg" width="80" height="30" /></a>
				</c:when>
				
				<c:otherwise >
				<a href="/RedboxSpringMVC/list.do"><img	src="images/checkout.jpg" width="80" height="30" /></a>
				</c:otherwise>
			</c:choose>	
			</td>
		</tr>
	</table>
<br>
<hr>
<br>
   <table border="0">
		<tr>
			<c:forEach items="${movies}" var="movie">
				<td><img src="${movie.imageLocation}" width="150" height="225"></td>
			</c:forEach>
		</tr>
		<tr>
			<c:forEach items="${movies}" var="movie">
				<td>
					<a href="/RedboxSpringMVC/addToCart.do?id=${movie.id}" >Add to<img src="images/cart.jpg" width="30" height="25"></a>
				</td>
			</c:forEach>	
		</tr>
	</table>
	
	<%@include file="Footer.jsp"%>
</body>
</html>